#include "PrecompiledHeaders.h"
#include "ReplayManager.h"
#include "ReplayState.h"
#include "ReplayController.h"
#include "GameSession.h"
#include "Player.h"

/*
 * Grab state pointers
 */
void ReplayManager::getStatePointers()
{
    PlayManager::getStatePointers();
}

/*
 * Load the quick play level select screen
 */
void ReplayManager::enter(void)
{    
    // Display beginning story mode screen
    menu->setLayout((LayoutType)LOAD_REPLAY);
    pushGameState(findByName("in_game_menu"));
    currentState = psLOADING;
}

void ReplayManager::resume(void)
{
    updateStateFromMenu();
    Player *p;
    switch(currentState)
    {
        case psPLAY_REPLAY:
            p = GameResources::current_level->getPlayer();
            p->setSession(new GameSession());
            PlayState::addPlayer(p, true);
	        ReplayState::addReplay(new ReplayController(filename));
	        pushGameState(findByName("replay"));
	        currentState = psFINISHED;
            break;
            
        case psFINISHED:
            popGameState();
            break;

        default:
            break;
    }
}

void ReplayManager::setReplay(std::string filename_)
{
    filename = filename_;
}
